using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Lesson5 : MonoBehaviour
{
    // Start is called before the first frame update
    public Button btnLoadScene;
    public Text txtProgress;
    void Start()
    {
        ListenerMgr.GetInstance().AddTrigger<float>("SceneProgress", SceneProgress);
        btnLoadScene.onClick.AddListener(LoadScene);
    }

    public void SceneProgress(float progress)
    {
        txtProgress.text = string.Format("{0}%", (int)progress * 100);
        Debug.LogFormat("[Lesson5][SceneProgress] progress:{0}", progress);
    }

    //加载完成
    public void LoadSceneFinish()
    {
        Debug.LogFormat("LoadSceneFinish...");
    }

    public void LoadScene()
    {
        btnLoadScene.interactable = false;
        Debug.LogFormat("LoadScene...");
        ScenesMgr.GetInstance().LoadSceneAsync("Lesson5_Test", LoadSceneFinish);
        btnLoadScene.interactable = true;
    }
}
